<?php
try{
    include '../ini.php';
    include '../classes/xl_banner.php';
    $dt_xl_banner=new xl_bannner;
    $location_banner=$dt_xl_banner->read_list();
    $read_products=$dt_xl_banner->read_product();
    $read_location=$dt_xl_banner->read_location();
    $dt_smarty->assign('read_location',$read_location);
    $dt_smarty->assign('location_banner',count($location_banner));
    $dt_smarty->assign('read_products',$read_products);
    $contenForLayout=$dt_smarty->fetch('banner/banner_add.tpl');
    $dt_smarty->assign('titleForLayout','Thêm quảng cáo');
    $dt_smarty->assign('contenForLayout',$contenForLayout);
    $dt_smarty->display('layout/defaults.tpl');
    $dbh=NULL;
}catch(Exception $e){
    $dbh=NULL;
    $_SESSION['msg']=$e->getMessage();
    $_SESSION['type_msg']='error';
    header('Location: banner_add.php');
}
function print_list($list,$id,$characters){
        foreach($list as $location):
            if($location['parent']==$id):
                echo '<option value="'.$location['id'].'">'.$characters,$location['name'].'</option>';
                print_list($list,$location['id'],$characters.$characters);
            endif;
        endforeach;
}